/*
 * RefCount.h
 *
 *  Created on: Nov 10, 2008
 *      Author: brain
 */

#ifndef ALPHAEXPANSION_H_
#define ALPHAEXPANSION_H_

//#include "CvImageGraph.h"
#include "Neighbors.h"
#include "Energy.h"
#include "graph.h"

#include <limits>

//const double infinty= numeric_limits<double>::max();

double neighboorweight(uint x1,uint y1,uint x2,uint y2);
typedef Graph<double,double,double> GraphType;
class AlphaExpansion
{
private:
    //* will be created by AlphaExpansion
    Energy *_energy;
    Neighbors nbrs;
	CVImage *labelling;//* the output image
	GraphType *graph;//* the generated graph
	uint current_iteration;
	//* initialized from the outside

	vector<int> *_labels;//* the labels set
public:

	void Labeled2Graph(int label);//* generates the graph from the given image and the current step labelling
	void GenerateLabelling(int label);
	uint IndeX(uint x,uint y);
    CVImage* next_iteration();//* one step of alpha expansion

    bool iscomplete();//* if all alpha expansion moves are done.

	AlphaExpansion(Energy&,CVImage *image,vector<int> *labels);//* constructor
	~AlphaExpansion();//* destructor

};

#endif /* ALPHAEXPANSION_H_ */
